package com.pshdhx.aiagent.rag;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.document.Document;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.ai.transformer.KeywordMetadataEnricher;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @Author pansd
 * @Date 2025-07-07 20:19
 * @Des Spring AI 自动提取 markdown文本中的元信息metadata 标签
 */
@Configuration
public class MetaDataExtractConfig {

    @Resource
    private ChatModel dashscopeChatModel;

    List<Document> extractMetaData(List<Document> documents) {
        KeywordMetadataEnricher keywordMetadataEnricher = new KeywordMetadataEnricher(this.dashscopeChatModel, 5);
        return keywordMetadataEnricher.apply(documents);
    }

}
